<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/include/taglibs.jsp"%>
<script type="text/javascript">
//오늘날짜
var nowDate = null;
//화면에 보이는 설정된 날짜
var setDate = null;

var rooms = null;
//핫 튜스 롤링
var rollCnt = 1;
var rollMaxcnt=0;
function hotRolling(){
	if(rollCnt==(rollMaxcnt-1)){
		rollCnt=0;
	}
	
	$("#hotNew > div").hide();
// 	$("#hot"+rollCnt).slideDown();
	$("#hot"+rollCnt).show();	
	rollCnt++;
}
$(document).ready(function(){
	
});

//그룹을 체크한 경우
function chkedGroup(dt, pg_no,me){
// 	console.log(me);
	if(me=="checked"){
		$("span.siteList_"+dt).find("input.pg_no_"+pg_no).attr("checked", true);	
	}else{
		$("span.siteList_"+dt).find("input.pg_no_"+pg_no).attr("checked", false);
	}
	
}

//테이블에 쓸 객실명 가져오기
var tableRooms="";
function getTableRooms(){
	if(tableRooms==""){
		tableRooms=setTableList();
	}
	return tableRooms;
}

//예약페이지로 이동
function goReserrvation(p_id,me,pr_no){

var r_date = $(me).parent().parent().parent().parent().parent().parent().parent().attr("id").replace("day_","");
	location.href="./pere200Q.do?p_id="+p_id+"&reservation_dt="+r_date+"&pr_no="+pr_no;
}

function setMoney(key,type,initYn){
	if("Y"==initYn){
		$("#pm_dc_m_"+key).val("");
		$("#pm_per_"+key).val("");
	}
	
	if('1'==type){
		//퍼센트 할일일때
		$("#pm_dc_m_"+key).val("");
	}else if('2'==type){
		//만원단위 할일일때
		$("#pm_per_"+key).val("");
	}
	var pm_per = Number($("#pm_per_"+key).val());
	var pm_dc_m = Number($("#pm_dc_m_"+key).val())*1000;
		
	$("#pm_per_"+key).parent().find("input[name='pm_pers']").val(pm_per);
	$("#pm_per_"+key).parent().find("input[name='busy_types']").val($("input[name=busy_type_"+key+"]:checked").val());
	$("#pm_per_"+key).parent().find("input[name='pm_dc_ms']").val(pm_dc_m);
	
}

//달력에 표시할수 있도록 테이블로 만들어둠
function setTableList(){
	//아이콘 보여줄지 여부
	var p_ico_yn = rooms.list[0].p_ico_yn;
	var html="";
	html+="<br/><span class='divDel'>"+
	<c:if test="${'Y'==pensionInfo.busy1_yn }">
	"<label><input name='busy_type_@@date' onclick=\"setMoney('@@date','1','Y');\" value='0101' type='radio'   />비수기 주중</label><br/> "+
		<c:if test="${'N'!=pensionInfo.friday_yn }">
		"<label><input name='busy_type_@@date' onclick=\"setMoney('@@date','1','Y');\" value='0102' type='radio'  />비수기 금요일</label><br/> "+
		</c:if>
	"<label><input name='busy_type_@@date' onclick=\"setMoney('@@date','1','Y');\" value='0103' type='radio'  />비수기 토요일</label><br/> "+
	</c:if>
	<c:if test="${'Y'==pensionInfo.busy2_yn }">
	"<label><input name='busy_type_@@date' onclick=\"setMoney('@@date','1','Y');\" value='0104' type='radio'   />준수기 주중</label><br/> "+
		<c:if test="${'N'!=pensionInfo.friday_yn }">
		"<label><input name='busy_type_@@date' onclick=\"setMoney('@@date','1','Y');\" value='0105' type='radio'  />준수기 금요일</label><br/> "+		
		</c:if>
	"<label><input name='busy_type_@@date' onclick=\"setMoney('@@date','1','Y');\" value='0106' type='radio'  />준수기 토요일</label><br/> "+
	</c:if>
	<c:if test="${'Y'==pensionInfo.busy3_yn }">
	"<label><input name='busy_type_@@date' onclick=\"setMoney('@@date','1','Y');\" value='0107' type='radio'   />성수기 주중</label><br/> "+
		<c:if test="${'N'!=pensionInfo.friday_yn }">
		"<label><input name='busy_type_@@date' onclick=\"setMoney('@@date','1','Y');\" value='0108' type='radio'  />성수기 금요일</label><br/> "+		
		</c:if>
	"<label><input name='busy_type_@@date' onclick=\"setMoney('@@date','1','Y');\" value='0109' type='radio'  />성수기 토요일</label><br/> "+
	</c:if>
	"<label><input name='busy_type_@@date' onclick=\"setMoney('@@date','1','Y');\" value='0110' type='radio'   />휴무</label><br/> "+
	"<input id='pm_per_@@date' name='pm_per_@@date' value='' type='text' style='width:40px' onkeyup=\"setMoney('@@date','1');\" />%할인 <br/>"+
	"<input id='pm_dc_m_@@date' name='pm_dc_m_@@date' value='' type='text' style='width:40px' onkeyup=\"setMoney('@@date','2');\" /> 천원할인"+
	
	"<input name='pm_dts' value='@@date' type='hidden' style='width:40px'/>"+
	"<input name='busy_types' value='' type='hidden' style='width:40px'/>"+
	"<input name='pm_dc_ms' value='0' type='hidden' style='width:40px'/>"+
	"<input name='pm_pers' value='0' type='hidden' style='width:40px'/>"+
	"</span>";
	
	return html;
}

//다음달 표시 옵션
var nextMonthYn=true;

//달력을 갱신한다
function changeNewDate(plusVal){
	setDate = new Date(${yyyy },${mm-1},1);
	setDate.addMonths(plusVal);
	location.href="?p_id=${param.p_id}&reservation_dt="+	setDate.toString("yyyyMMdd");
}

//프로모션 저장
function saveData(dt){
	$("#reservation_dt").val(dt);
	$("#addParam").html("");
// 	int pr_no = (int) vo.getPr_nos()[vo.getPr_no_cnts()[i]];
// 	int rsv_days = (int) vo.getRsv_days()[vo.getPr_no_cnts()[i]];

// <form action="./petc1005T.do"  id="frmData" method="post">
// <input type="hidden" name="p_id" value="${param.p_id}">
	var rsv_days = $("#day_"+dt).find("select > option:selected").val();
	var rrr_pays = 0;
	var tmp = $("#day_"+dt).find("input[name='rrr_pays']").val();
	if(""!=tmp){
		rrr_pays = Number(tmp)*1000;
	}
// 	alert(rsv_days);
// 	alert(rrr_pays);
	
	$(".siteList_"+dt).find("input[name='pr_no']:checked").each(function (i){
		var html = "<input name='pr_no_cnts' type='text' value='"+i+"' />";
		html += "<input name='pr_nos' type='text' value='"+$(this).val()+"' />";
		html += "<input name='rsv_days' type='text' value='"+rsv_days+"' />";
		html += "<input name='rrr_pays' type='text' value='"+rrr_pays+"' />";
		
		$("#addParam").append(html);
	});
	
	if(confirm("저장하시겠습니까?")){
		$("#frmData").submit();	
	}
}

//그룹인자 사이트인지 표출
function 	showType1(type){
	if("1"==type){
		$(".groupList").show();
		$(".siteList").hide();
	}else{
		$(".groupList").hide();
		$(".siteList").show();
	}
}
</script>

<a href="./petc1004Q.do?p_id=${param.p_id }">
연박설정
</a>
<table width="100%" border="0" cellspacing="0" cellpadding="10">
  <tr>
    <td>

<!-- 달력 시작 -->
<div style="display: none">
	<form action="./petc1005T.do"  id="frmData" method="post">
	<input type="text" name="p_id" value="${param.p_id}">
	<input type="text" name="reservation_dt" id="reservation_dt" value="">
	<input type="text" name="rm_status" id="rm_status" value="">
	
	<div id="addParam">
	</div>
	
	</form>
</div>
<table width=100% border="0" cellspacing="0" cellpadding="5">
	<tr>
		<td>

		<table style="width: 100%">
			<tr>
				<td colspan="7" style="text-align: center;">
					<div>
						<a href="#" onclick="changeNewDate(-1);" ><img alt="" src="/camping/img/calendar_arrow_l.jpg"  style="vertical-align:top; padding-top: 20px;padding-right: 10px;"></a>
						<strong style="font-size: 36px;font-weight: bold;font-family: Arial Black" id="yyyyMM">${yyyy }년 ${mm }월</strong>
						<a href="#" onclick="changeNewDate(1);" ><img alt="" src="/camping/img/calendar_arrow_r.jpg" style="vertical-align:top; padding-top: 20px;padding-left : 10px;"></a>
					</div>
					
					<div style=""> <input onclick="showType1('1');" name="showType" type="radio" checked="checked">그룹, <input onclick="showType1('2');" name="showType" type="radio">사이트</div>
					<div style="padding-left: 0px;float: right;"><strong style="color: #ff9f52; ">TODAY : ${nDtAll }</strong></div>
				</td>
			</tr>
		</table>
		<table class="cal1">
			<tr id="calTitle">
				<th class="calRed">일요일</th>
				<th class="calBlack">월요일</th>
				<th class="calBlack">화요일</th>
				<th class="calBlack">수요일</th>
				<th class="calBlack">목요일</th>
				<th class="calBlack">금요일</th>
				<th class="calBlue">토요일</th>
			</tr>
			${calendar }
		</table>
		</td>
	</tr>
</table>

<!-- 	달력 종료 -->
	</td>
  </tr>
</table>